package com.api.regression.group.deletedocument;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IGroupApiService;
import com.zyncro.api.exceptions.ZyncroApiException;

@ContextConfiguration(locations = { "classpath:/group/group-context.xml" })
public class DeleteDocumentNotParticipant extends AbstractApiTest {

	@Value("#{editgroupdocuments['user.notParticipant'].appId}")
	private String userUrn;

	@Value("#{editgroupdocuments['user.notParticipant'].password}")
	private String userPassword;

	@Value("#{editgroupdocuments['group.toDeleteNotOwner'].urn}")
	private String groupUrn;

	@Value("#{editgroupdocuments['group.toDeleteNotOwner'].folderUrn}")
	private String folderUrn;

	@Value("#{editgroupdocuments['group.toDeleteNotOwner'].fileUrn}")
	private String fileUrn;

	@Value("#{editgroupdocuments['group.toDeleteNotOwner'].linkUrn}")
	private String linkUrn;

	@Value("#{editgroupdocuments['group.toDeleteNotOwner'].shortcutUrn}")
	private String shortcutUrn;

	@BeforeClass
	protected void loginUser() throws Exception {

		getApi().login(userUrn, userPassword);
	}

	@Test(expectedExceptions = { ZyncroApiException.class })
	public void testDeleteFolder() throws ZyncroApiException {

		getApi().getService(IGroupApiService.class).deleteDocument(groupUrn, folderUrn);
	}

	@Test(expectedExceptions = { ZyncroApiException.class })
	public void testDeleteFile() throws ZyncroApiException {

		getApi().getService(IGroupApiService.class).deleteDocument(groupUrn, fileUrn);
	}

	@Test(expectedExceptions = { ZyncroApiException.class })
	public void testDeleteLink() throws ZyncroApiException {

		getApi().getService(IGroupApiService.class).deleteDocument(groupUrn, linkUrn);
	}

	@Test(expectedExceptions = { ZyncroApiException.class })
	public void testDeleteShortcut() throws ZyncroApiException {

		getApi().getService(IGroupApiService.class).deleteDocument(groupUrn, shortcutUrn);
	}

}
